package cn.db101.fairy.model

import cn.hutool.http.HttpStatus

/**
 * @author zooy
 * @create 2024-06-29 15:26
 * @description
 */
class ResultModel<T> {

    var code: Int? = null

    var message: String? = null

    var data: T? = null

    companion object {
        fun <T> wrapSuccessResult(data: T): ResultModel<T> {
            val result = ResultModel<T>()
            result.data = data
            result.code = HttpStatus.HTTP_OK
            return result
        }

        fun <T> wrapSuccessResult(): ResultModel<T> {
            val result = ResultModel<T>()
            result.code = HttpStatus.HTTP_OK
            return result
        }

        fun <T> wrapErrorResult(message: String): ResultModel<T> {
            val result = ResultModel<T>()
            result.code = HttpStatus.HTTP_INTERNAL_ERROR
            result.message = message
            return result
        }

    }

}
